<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head th:include="include :: header"></head>
<body class="hold-transition skin-blue sidebar-mini">
<section class="content-header">
    <h1>
        工具库台账列表
    </h1>
</section>
<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header">
                    <form id="queryForm" onsubmit="return false;">
                        <div class="row">
                            <div class="form-inline">
                                <div class="form-group" style="margin-right: 10px;">
                                    <label>厂内编号</label>
                                    <input type="text" name="toolCode" class="form-control" placeholder="请输入厂内编号或名称">
                                </div>
                                <div class="form-group" style="margin-right: 10px;">
                                    <label>规格型号</label>
                                    <input type="text" name="toolSat" class="form-control" placeholder="请输入材质">
                                </div>
                                <div class="form-group" style="margin-right: 10px;">
                                    <label>品牌</label>
                                    <input type="text" name="toolBra" class="form-control" placeholder="请输入品级">
                                </div>
                                <div class="form-group" style="margin-right: 10px;">
                                    <label>跟踪号</label>
                                    <input type="text" name="toolFollow" class="form-control" placeholder="请输入具体位置">
                                </div>

                                <div class="form-group" style="margin-right: 10px;margin-top: 5px;">
                                    <label>状态</label>
                                    <input type="text" name="toolStatus" class="form-control" placeholder="请输入使用状态">
                                </div>

                                <div class="form-group" style="margin-right: 10px;">
                                    <label>所属部门</label>
                                    <input type="text" name="toolWork" class="form-control" placeholder="请输入使用部门">
                                </div>

                                <div class="form-group">
                                    <label>台账类型</label>
                                    <select name="fkTypeId" class="form-control" style="width:200px;" id="eqmFkTypeEdit">
                                        <option value="" selected="selected">全部</option>
                                        <option th:each="type : ${typelist}" th:value="${type.typId}" th:text="${type.typName}"></option>
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label>月份</label>
                                    <input type="text" class="form-control"  name="toolMonth" id="eqmMonthAdd"  readonly="readonly" style="width: 102px; height: 34px; padding-right: 0px;">
                                </div>
                                <button type="button" class="btn btn-success" id="btn-search" style="margin-top: 5px;">
                                    <!--<i class="fa fa-search"></i>-->
                                    <span class="Bold">搜索</span>
                                </button>
                            </div>
                        </div>
                        <div class="row form-inline" id="toolbar">



                            <a href="javascript:void(0);" class="btn btn-info pull-right" onclick="uploadFile()" style="margin-top: 5px;" shiro:hasPermission="drive:toolsb:add">
                                <!--<i class="fa fa-plus"></i>-->
                                <span class="Bold">上传</span>
                            </a>

                            <a href="javascript:void(0);" class="btn btn-info pull-right" onclick="addType()" style="margin-right: 10px;margin-top: 5px;margin-right: 10px;" shiro:hasPermission="drive:toolsb:add">
                                <!--<i class="fa fa-plus"></i>-->
                                <span class="Bold">添加</span>
                            </a>
                        </div>
                    </form>
                </div>
                <div class="box-body" style=" overflow: auto;">
                    <table id="bootstrap-table" style="table-layout: fixed;word-break:break-all; word-wrap:break-word;"></table>
                </div>
            </div>
        </div>
    </div>
</section>
<!--创建类型模态框-->
<div class="modal fade" id="modal-create-type">
    <div class="modal-dialog" style="width:800px;">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">新增工具库台账信息</h4>
            </div>
            <div class="modal-body" style="padding: 0px;">
                <form id="typeForm-create" class="form-horizontal">
                    <div class="col-md-12" style="padding-top: 15px;">
                        <div class="form-group">
                            <label class="col-sm-4 control-label">台账类型</label>
                            <div class="col-sm-8">
                                <select name="fkTypeId" class="form-control" style="width:200px;" id="eqmFkTypeEdt">
                                    <option th:each="type : ${typelist}" th:value="${type.typId}" th:text="${type.typName}"></option>
                                </select>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-4 control-label">月份</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control"  name="toolMonth" id="toolMonthAdd"  readonly="readonly" style="width: 102px; height: 34px; padding-right: 0px;">
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-sm-4 control-label">排序</label>
                            <div class="col-sm-8">
                                <input type="number" step="1" class="form-control" name="toolSortNum" autocomplete="off" placeholder="排序">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">工具名称</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" name="toolName" autocomplete="off" placeholder="工具名称">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">厂内编号</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" name="toolCode" autocomplete="off" placeholder="厂内编号">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">规格型号</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" name="toolSat" autocomplete="off" placeholder="规格型号">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">出厂编号</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" name="toolOutCode" autocomplete="off" placeholder="出厂编号">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">数量</label>
                            <div class="col-sm-8">
                                <input type="number" step="1"  class="form-control" name="toolNum" autocomplete="off" placeholder="数量">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">品牌</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" name="toolBra" autocomplete="off" placeholder="品牌">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">精度</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" name="toolFlot" autocomplete="off" placeholder="精度">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">生产日期</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" name="toolProDate" autocomplete="off" placeholder="生产日期">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">使用人</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" name="toolLble" autocomplete="off" placeholder="使用人">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">厂牌号</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" name="toolUserCode" autocomplete="off" placeholder="厂牌号">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">领用时间</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" name="toolColDate" autocomplete="off" placeholder="领用时间">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">跟踪号</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" name="toolFollow" autocomplete="off" placeholder="跟踪号">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">用途</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" name="toolPur" autocomplete="off" placeholder="用途">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">状态</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" name="toolStatus" autocomplete="off" placeholder="状态">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">所属部门</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" name="toolWork" autocomplete="off" placeholder="所属部门">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">变更信息</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" name="toolChange" autocomplete="off" placeholder="变更信息">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">备注</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" name="toolRemark" autocomplete="off" placeholder="备注">
                            </div>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-info" id="btn-create-type">提交</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
            </div>
        </div>
    </div>
</div>

<!--编辑类型模态框-->
<div class="modal fade" id="modal-edit-type">
    <div class="modal-dialog" style="width:800px;">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">编辑工具库台账信息</h4>
            </div>
            <div class="modal-body" style="padding: 0px;">
                <form id="typeForm-edit" class="form-horizontal">
                    <div class="col-md-12" style="padding-top: 15px;">
                        <input type="hidden" name="toolId"/>
                        <div class="form-group">
                            <div class="form-group">
                                <label class="col-sm-4 control-label">台账类型</label>
                                <div class="col-sm-8">
                                    <select name="fkTypeId" class="form-control" style="width:200px;" id="fkTypeIdEdit">
                                        <option th:each="type : ${typelist}" th:value="${type.typId}" th:text="${type.typName}"></option>
                                    </select>
                                </div>
                            </div>

                            <div class="form-group">
                                <label class="col-sm-4 control-label">月份</label>
                                <div class="col-sm-8">
                                    <input type="text" class="form-control"  name="toolMonth" id="eqmMonthEdit"  readonly="readonly" style="width: 102px; height: 34px; padding-right: 0px;">
                                </div>
                            </div>

                            <label class="col-sm-4 control-label">排序</label>
                            <div class="col-sm-8">
                                <input type="number" step="1" class="form-control" name="toolSortNum" autocomplete="off" placeholder="排序">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">工具名称</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" name="toolName" autocomplete="off" placeholder="工具名称">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">厂内编号</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" name="toolCode" autocomplete="off" placeholder="厂内编号">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">规格型号</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" name="toolSat" autocomplete="off" placeholder="规格型号">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">出厂编号</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" name="toolOutCode" autocomplete="off" placeholder="出厂编号">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">数量</label>
                            <div class="col-sm-8">
                                <input type="number" step="1"  class="form-control" name="toolNum" autocomplete="off" placeholder="数量">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">品牌</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" name="toolBra" autocomplete="off" placeholder="品牌">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">精度</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" name="toolFlot" autocomplete="off" placeholder="精度">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">生产日期</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" name="toolProDate" autocomplete="off" placeholder="生产日期">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">使用人</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" name="toolLble" autocomplete="off" placeholder="使用人">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">厂牌号</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" name="toolUserCode" autocomplete="off" placeholder="厂牌号">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">领用时间</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" name="toolColDate" autocomplete="off" placeholder="领用时间">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">跟踪号</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" name="toolFollow" autocomplete="off" placeholder="跟踪号">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">用途</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" name="toolPur" autocomplete="off" placeholder="用途">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">状态</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" name="toolStatus" autocomplete="off" placeholder="状态">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">所属部门</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" name="toolWork" autocomplete="off" placeholder="所属部门">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">变更信息</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" name="toolChange" autocomplete="off" placeholder="变更信息">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-4 control-label">备注</label>
                            <div class="col-sm-8">
                                <input type="text" class="form-control" name="toolRemark" autocomplete="off" placeholder="备注">
                            </div>
                        </div>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-info" id="btn-edit-type">提交</button>
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
            </div>
        </div>
    </div>
</div>

<!--导入模态框-->
<div class="modal fade" id="modal-import">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title">Excel信息导入</h4>
            </div>
            <div class="modal-body">
                <form id="importForm">
                    <div class="form-group">
                        <label>模版</label>
                        <a th:href="@{/file/工具台账模板.xlsx}">点击下载</a>
                    </div>
                    <div class="form-group">
                        <label>上次导入错误数据</label>
                        <a id="download-error"
                           th:data-url="@{/files/{user}/OffToolError.xls(user=${session.user.account})}"
                           href="javascript:void(0);">点击下载</a>
                    </div>

                    <div class="form-group">
                        <label>台账类型</label>
                        <select name="fkTypeId" class="form-control" style="width:200px;" id="eqmFkTypeAdd">
                            <option th:each="type : ${typelist}" th:value="${type.typId}" th:text="${type.typName}"></option>
                        </select>
                    </div>
                    <div class="form-group">
                        <label>月份</label>
                        <input type="text" class="form-control"  name="toolMonth" id="eqmMonthAdd2"  readonly="readonly" style="width: 102px; height: 34px; padding-right: 0px;">
                    </div>

                    <div class="form-group">
                        <label>选择Excel文件并上传</label>
                        <input class="btn" type="file" multiple="multiple" name="file">
                        <p class="help-block">请按模板格式进行导入，信息与模板信息对应。</p>
                    </div>

                    <!--<div class="form-group">-->
                    <!--<label for="browsefile">视频地址</label>-->
                    <!--<input type='file' id='browsefile' style="display: none" onchange='filepath.value=this.value'>-->
                    <!--<input type='textfield' id="filepath" disabled="disabled" style="background-color: #EEEEEE; border: solid 1px #d2d6de; line-height: 30px; height: 30px;" >-->
                    <!--<input type='button' id='filebutton' value='浏览这里随便写名字' onclick="browsefile.click()"  disabled="disabled" style="color: #737373;">-->
                    <!--</div>-->


                </form>
            </div>
            <div class="modal-footer">
                <button id="btn-upload" type="button" class="btn btn-success">
                    <span class="Bold">上传</span>
                </button>
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
            </div>
        </div>
    </div>
</div>

<div th:include="include :: footer"></div>

<script th:inline="javascript">

    /** 导入模态框隐藏事件，重置表单，重置验证 */
    js.modal.hideEvent("modal-create-type", function () {
        js.validate.reset("typeForm-create");
        js.reset("typeForm-create");
    });

    /** 导入表单验证 */
    js.validate.init("typeForm-create", {
        fields: {
            toolCode: {validators: {notEmpty: {message: '请输入厂内编号'},
                    remote: {
                        url: ctx + "tool/ku/checkUnique",
                        message: '厂内编号已存在',
                        delay: 200,
                        type: 'POST',
                        data: {
                            toolId: function () {
                                return "";
                            },
                            fkTypeId:function () {
                                return $("#eqmFkTypeEdt").find("option:selected").val();
                            },
                            toolMonth:function () {
                                return $("#toolMonthAdd").val();
                            }
                        }
                    }
                }
            },
            toolName:{validators: {notEmpty: {message: '请输入工具名称'}}},
            toolNum:{validators: {notEmpty: {message: '请输入数量'}}},
            fkTypeId:{validators: {notEmpty: {message: '请选择类型'}}},
            toolMonth:{validators: {notEmpty: {message: '请选择月份'}}}
        }
    });

    /** 导入模态框隐藏事件，重置表单，重置验证 */
    js.modal.hideEvent("modal-edit-type", function () {
        js.validate.reset("typeForm-edit");
        js.reset("typeForm-edit");
    });

    /** 导入表单验证 */
    js.validate.init("typeForm-edit", {
        fields: {
            toolCode: {validators: {notEmpty: {message: '请输入厂内编号'},
                    remote: {
                        url: ctx + "tool/ku/checkUnique",
                        message: '厂内编号已存在',
                        delay: 200,
                        type: 'POST',
                        data: {
                            toolId: function () {
                                return  $("#typeForm-edit input[name='toolId']").val();
                            },
                            fkTypeId:function () {
                                return $("#fkTypeIdEdit").find("option:selected").val();
                            },
                            toolMonth:function () {
                                return $("#eqmMonthEdit").val();
                            }
                        }
                    }
                }
            },
            toolName:{validators: {notEmpty: {message: '请输入工具名称'}}},
            toolNum:{validators: {notEmpty: {message: '请输入数量'}}},
            fkTypeId:{validators: {notEmpty: {message: '请选择类型'}}},
            toolMonth:{validators: {notEmpty: {message: '请选择月份'}}}
        }
    });

    /*
    *上传文件
     */
    function uploadFile(){
        /**
         * 时间默认为本月
         */
        $("input[id='eqmMonthAdd2']").val(new Date().format('yyyy-MM'));
        js.updateDatePicker();
        js.modal.open("modal-import");
    }
    /** 导入表单验证 */
    js.validate.init("importForm", {
        fields: {
            file: {
                validators: {
                    notEmpty: {message: '上传文件不能为空'},
                    file: {extension: 'xls,xlsx', message: '请选择excel文件'}
                }
            }
        }
    });

    /** 导入模态框隐藏事件，重置表单，重置验证 */
    js.modal.hideEvent("modal-import", function () {
        js.validate.reset("importForm");
        js.reset("importForm");
    });

    /*
    *添加类型
     */
    function addType(){
        /**
         * 时间默认为本月
         */
        $("input[id='toolMonthAdd']").val(new Date().format('yyyy-MM'));
        js.updateDatePicker();
        js.modal.open("modal-create-type");
    }
    /** 导入设备台账信息 */
    $("#btn-upload").click(function () {
        var $this = $(this);
        $this.attr('disabled', true);
        js.validSubmit({
            formId: "importForm",
            url: ctx + "tool/ku/import",
            data: new FormData($("#importForm")[0]),
            success: function (result) {
                if (result.type === web_status.SUCCESS) {
                    js.modal.success(result.msg);
                    js.table.refresh(table);
                    js.modal.hide("modal-import");
                    $this.attr('disabled', false);
                }
            }
        });
    });
    /** 创建类型 */
    $("#btn-create-type").click(function () {
        if (js.validate.isValid("typeForm-create")) {
            js.post({
                url: ctx + "tool/ku/add",
                data: $("#typeForm-create").serialize(),
                success: function (result) {
                    if (result.type === web_status.SUCCESS) {
                        js.modal.success(result.msg);
                        js.table.refresh(table);
                        js.modal.hide("modal-create-type");
                    } else {
                        js.modal.warning(result.msg);
                    }
                    js.modal.closeLoading();
                }
            });
        }
    });

    /** 创建类型 */
    $("#btn-edit-type").click(function () {
        if (js.validate.isValid("typeForm-edit")) {
            js.post({
                url: ctx + "tool/ku/edit",
                data: $("#typeForm-edit").serialize(),
                success: function (result) {
                    if (result.type === web_status.SUCCESS) {
                        js.modal.success(result.msg);
                        js.table.refresh(table);
                        js.modal.hide("modal-edit-type");
                    } else {
                        js.modal.warning(result.msg);
                    }
                    js.modal.closeLoading();
                }
            });
        }
    });

    /*
    *编辑类型
     */
    function editType(row){
        $("#typeForm-edit").fillData(row);

        js.modal.open("modal-edit-type");
    }
    /*
    *删除类型
     */
    function delType(id){
        js.confirmPost({
            content: "删除数据将无法恢复，确认删除吗？",
            url: ctx + "tool/ku/del",
            data: {"empId":id},
            success: function (result) {
                if (result.type === web_status.SUCCESS) {
                    js.modal.success(result.msg);
                    js.table.refresh(table);
                    js.modal.hide("modal-edit-type");
                } else {
                    js.modal.warning(result.msg);
                }
                js.modal.closeLoading();
            }
        });
    }

    var table;

    $(function () {
        /**
         * 日期控件的格式化
         */
        $("#eqmMonthAdd").datepicker({
            format: 'yyyy-mm',
            language: 'zh-cn',
            autoclose: true,
            clearBtn: true,
            minViewMode: 1 // 最小精度选择
        }).on('hide', function (event) {
            event.stopPropagation();
        });

        /**
         * 时间默认为本月
         */
        $("input[id='eqmMonthAdd']").val(new Date().format('yyyy-MM'));
        js.updateDatePicker();


        /**
         * 日期控件的格式化
         */
        $("#eqmMonthAdd2").datepicker({
            format: 'yyyy-mm',
            language: 'zh-cn',
            autoclose: true,
            clearBtn: false,
            minViewMode: 1 // 最小精度选择
        }).on('hide', function (event) {
            event.stopPropagation();
        });


        /**
         * 日期控件的格式化
         */
        $("#toolMonthAdd").datepicker({
            format: 'yyyy-mm',
            language: 'zh-cn',
            autoclose: true,
            clearBtn: false,
            minViewMode: 1 // 最小精度选择
        }).on('hide', function (event) {
            event.stopPropagation();
        });



        /**
         * 日期控件的格式化
         */
        $("#eqmMonthEdit").datepicker({
            format: 'yyyy-mm',
            language: 'zh-cn',
            autoclose: true,
            clearBtn: false,
            minViewMode: 1 // 最小精度选择
        }).on('hide', function (event) {
            event.stopPropagation();
        });

        /** 加载用户表格 */
        table = js.table.init({
            url: ctx + "tool/ku/list",
            showColumns: true,
            showExport: false,
            pageSize:10,
            exportOptions:{
                ignoreColumn: [19,20,21,22,23]
            },
            columns: [
                {
                    title: '序号', field: 'id', width: '50',
                    formatter: function (value, row, index, field) {
                        var pageSize = table.bootstrapTable('getOptions').pageSize;
                        var pageNumber = table.bootstrapTable('getOptions').pageNumber;
                        return pageSize * (pageNumber - 1) + index + 1;
                        // return index + 1;
                    }
                },
                { title: "类型", field: 'typName',width: '100'},
                { title: "月份", field: 'toolMonth',width: '100'},
                { title: "厂内编号", field: 'toolCode',width: '200'},
                { title: "工具名称", field: 'toolName',width: '200'},
                { title: "规格型号", field: 'toolSat',width: '200'},
                { title: "出厂编号", field: 'toolOutCode',width: '200'},
                { title: "数量", field: 'toolNum',width: '100'},
                { title: "品牌", field: 'toolBra',width: '200'},
                { title: "精度", field: 'toolFlot',width: '200'},
                { title: "生产日期", field: 'toolProDate',width: '200'},
                { title: "使用人", field: 'toolLble',width: '100'},
                { title: "厂牌号", field: 'toolUserCode',width: '200'},
                { title: "领用时间", field: 'toolColDate',width: '200'},
                { title: "跟踪号", field: 'toolFollow',width: '200'},
                { title: "用途",field: 'toolPur',width: '200'},
                { title: "状态", field: 'toolStatus',width: '200'},
                { title: "所属部门", field: 'toolWork',width: '200'},
                { title: "变更信息", field: 'toolChange',width: '200'},
                { title: "备注", field: 'toolRemark',width: '200'},
                { title: "排序", field: 'toolSortNum',width: '100'},
                { title: "创建人", field: 'toolCreUser',width: '70'},
                { title: "创建时间", field: 'toolCreDate',width: '100'},
                { title: "修改人", field: 'toolUpdUser',width: '70'},
                { title: "修改时间", field: 'toolUpdDate',width: '100'},

                // { title: "厂内编号", field: 'toolCode'},
                // { title: "工具名称", field: 'toolName'},
                // { title: "规格型号", field: 'toolSat'},
                // { title: "出厂编号", field: 'toolOutCode'},
                // { title: "数量", field: 'toolNum'},
                // { title: "品牌", field: 'toolBra'},
                // { title: "精度", field: 'toolFlot'},
                // { title: "生产日期", field: 'toolProDate'},
                // { title: "使用人", field: 'toolLble'},
                // { title: "厂牌号", field: 'toolUserCode'},
                // { title: "领用时间", field: 'toolColDate'},
                // { title: "跟踪号", field: 'toolFollow'},
                // { title: "用途",field: 'toolPur'},
                // { title: "状态", field: 'toolStatus'},
                // { title: "所属部门", field: 'toolWork'},
                // { title: "变更信息", field: 'toolChange'},
                // { title: "备注", field: 'toolRemark'},
                // { title: "排序", field: 'toolSortNum'},
                // { title: "创建人", field: 'toolCreUser'},
                // { title: "创建时间", field: 'toolCreDate'},
                // { title: "修改人", field: 'toolUpdUser'},
                // { title: "修改时间", field: 'toolUpdDate'},
                //
                {
                    title: "操作",
                    width: '140',
                    formatter: function (value, row, index) {
                        var actions = [];
                        if (hasP("drive:toolsb:edit")) {
                            actions.push('<a class="btn btn-warning btn-xs" href="javascript:void(0)" onclick="editType(' + js.jsonStringify(row) + ')"> 编辑</a> ');
                        }
                        if (hasP("drive:toolsb:del")) {
                            actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)"  onclick="delType(' + row.toolId + ')"> 删除</a> ');
                        }
                        return actions.join('');
                    }
                }
            ]
        });

        /**
         * 表格搜索
         */
        $("#btn-search").click(function () {
            js.table.search(table);
        });

        //导出的权限
        if(!hasP("drive:toolsb:edit")){
            $("div[class='export btn-group']").children().remove();
        }

    });

    /** 下载导入失败excel */
    $("#download-error").click(function () {
        var that = $(this);
        js.post({
            url: ctx + "tool/ku/exist",
            async: false,
            data: {
                url: that.attr("data-url")
            },
            success: function (result) {
                if (result.type === web_status.SUCCESS) {
                    that.attr("href", that.attr("data-url") + "?timeStamp=" + new Date().getTime());
                } else {
                    js.modal.warning("没有需要处理的文件");
                }
            }
        });
    });

</script>